package com.lab.utils.imageupload.imp;

import com.alibaba.sdk.android.oss.common.auth.OSSFederationCredentialProvider;
import com.alibaba.sdk.android.oss.common.auth.OSSFederationToken;
import com.lab.utils.imageupload.model.OssTokenObject;

/**
 * Created by ak
 * 重载OSSFederationCredentialProvider生成自己的获取STS的功能
 */
public class STSGetter extends OSSFederationCredentialProvider {

    private OssTokenObject ossTokenObject;

    public STSGetter(OssTokenObject ossTokenObject) {
        this.ossTokenObject = ossTokenObject;
    }


    public OSSFederationToken getFederationToken() {
        /*ApiProxy apiProxy = new ApiProxy(null);
        ProxyResult proxyResult =  CommonBusiness.getMobileOssToken(apiProxy);
        CtApiResponse response = (CtApiResponse) proxyResult.getData();
        if (response.isResponseNormal()){
            OssTokenObject ossTokenObject = (OssTokenObject) response.result;
            */
        return new OSSFederationToken(ossTokenObject.getAccessKeyId(), ossTokenObject.getAccessKeySecret(),
                ossTokenObject.getSecurityToken(), ossTokenObject.getExpiration());
//        }
//        return null;
    }

}
